﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.NeighborUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Events.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.event.*;
    import org.aswing.border.*;
    import Display.aswingui.*;
    import Modules.stats.types.*;

    public class NeighborActionsMenu extends Sprite {

        public static const BUTTON_SEND_GIFT:int = 0;
        public static const BUTTON_VISIT:int = 1;
        public static const BUTTON_CHALLENGE:int = 2;
        public static const SLOT_HEIGHT:int = 31;

        public const ACTIONS_MENU_SPACING:Number = 30;

        public var m_slots:Array;
        public var m_slotsNum:int;
        public var m_neighborName:String;
        public var m_commodities:Dictionary;
        protected var m_friend:Friend;
        protected var m_goodsText:JTextField;
        protected var m_innerPanel:JPanel;
        protected var m_buyBtn:JButton;
        protected var m_sellBtn:JButton;
        protected var m_remindBtn:JButton;
        protected var m_buttonPanel:JPanel;

        public function NeighborActionsMenu(_arg1:Friend){
            this.m_slots = [];
            super();
            this.m_friend = _arg1;
            this.m_commodities = _arg1.commodities;
            this.createBackground();
        }
        public function get friend():Friend{
            return (this.m_friend);
        }
        public function set friend(_arg1:Friend):void{
            this.m_friend = _arg1;
            this.m_commodities = _arg1.commodities;
        }
        private function createBackground():void{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, 0);
            this.m_innerPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, -3);
            this.m_innerPanel.setBorder(new EmptyBorder(null, new Insets(0, 0, 0, 0)));
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local3:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            ASwingHelper.setEasyBorder(_local3, 0, 10);
            addEventListener(MouseEvent.MOUSE_OVER, this.onMaskNeighborActions, false, 0, true);
            addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskNeighborActions, false, 0, true);
            addEventListener(MouseEvent.MOUSE_OUT, this.onMaskNeighborActions, false, 0, true);
            this.m_buttonPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            ASwingHelper.setEasyBorder(this.m_buttonPanel, 0, 15, 0, 15);
            this.m_remindBtn = new CustomButton(ZLoc.t("Dialogs", "Remind"), null, "OrangeMediumButtonUI");
            this.m_buyBtn = new CustomButton(ZLoc.t("Dialogs", "Buy"), null, "OrangeMediumButtonUI");
            this.m_sellBtn = new CustomButton(ZLoc.t("Dialogs", "Sell"), null, "OrangeMediumButtonUI");
            this.m_remindBtn.setText(ZLoc.t("Dialogs", "Remind"));
            var _local4:DisplayObject = (new EmbeddedArt.nghbr_popup_bg() as DisplayObject);
            ASwingHelper.setSizedBackground(_local1, _local4, new Insets(3));
            this.m_innerPanel.appendAll(_local2, _local3, ASwingHelper.verticalStrut(5), this.m_buttonPanel);
            _local1.append(this.m_innerPanel);
            var _local5:JWindow = new JWindow(this);
            _local5.setContentPane(_local1);
            _local5.show();
            ASwingHelper.prepare(_local5);
        }
        public function setRemindMode():void{
            this.m_buttonPanel.remove(this.m_buyBtn);
            this.m_buttonPanel.remove(this.m_sellBtn);
            this.m_buyBtn.removeActionListener(this.onBuy);
            this.m_sellBtn.removeActionListener(this.onSell);
            this.m_buttonPanel.append(this.m_remindBtn);
            this.m_remindBtn.addActionListener(this.onRemind, 0, true);
        }
        public function setNormalMode():void{
            this.m_remindBtn.removeActionListener(this.onRemind);
            this.m_buttonPanel.remove(this.m_remindBtn);
            this.m_buyBtn.addActionListener(this.onBuy, 0, true);
            this.m_sellBtn.addActionListener(this.onSell, 0, true);
            this.m_buttonPanel.appendAll(this.m_buyBtn, this.m_sellBtn);
        }
        public function onMaskNeighborClickActions(_arg1:MouseEvent):void{
            _arg1.stopPropagation();
        }
        public function onMaskNeighborActions(_arg1:MouseEvent):void{
            _arg1.stopImmediatePropagation();
            _arg1.stopPropagation();
        }
        private function onBuy(_arg1:AWEvent):void{
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "buy");
            dispatchEvent(new FriendTradeEvent(FriendTradeEvent.BUY, this.m_friend));
        }
        private function onSell(_arg1:AWEvent):void{
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "sell");
            dispatchEvent(new FriendTradeEvent(FriendTradeEvent.SELL, this.m_friend));
        }
        private function onRemind(_arg1:AWEvent):void{
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "remind");
            dispatchEvent(new FriendTradeEvent(FriendTradeEvent.REMIND, this.m_friend));
        }

    }
}//package Display.NeighborUI 
